package com.dgshanger.sanhxiaofeisc.mvp.presenter

import com.dgshanger.sanhxiaofeisc.entity.ShareEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.SharedContract
import com.dgshanger.sanhxiaofeisc.mvp.model.SharedModel
import com.xx.baseuilibrary.mvp.BaseRxMvpPresenter
import com.xx.baseutilslibrary.network.rx.RxHttpObserver

/**
 * SharedPresenter
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/5/3 17:36.
 */

class SharedPresenter : BaseRxMvpPresenter<SharedContract.Model, SharedContract.View>(), SharedContract.Presenter {

    override fun createModel(): SharedContract.Model = SharedModel()

    override fun loadData() {
        getModel().loadData(object : RxHttpObserver<ShareEntity>() {
            override fun onCompleted(msg: String?, entity: ShareEntity?) {
                getView()?.setData(entity)
            }

            override fun onError(error: String?) {
                getView()?.showToast(error)
            }

            override fun onLoadingStart() {
                attachObserver(this)
                getView()?.showLoadingDialog()
            }

            override fun onLoadingFinish() {
                getView()?.dismissLoadingDialog()
            }
        })
    }
}
